// pages/more/more.js
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    current: 0,
    pageWrapCount: [],
    pIndex: [],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this
    var bgc = wx.getStorageSync('color')
    wx.setNavigationBarColor({
      frontColor: "#ffffff",
      backgroundColor: bgc,
    })
    app.util.request({
      url: 'entry/wxapp/Yuzhen.classa',
      'cachetime': '30',
      success: function (res) {
        var id = res.data[0].id;
        app.util.request({
          url: 'entry/wxapp/Yuzhen.classb',
          data: { id: id },
          success: function (res) {
            console.log(res.data)
            that.setData({
              categoryfl2: res.data,
            })
            app.globalData.skuList = res.data;
            var pIndex = that.data.pIndex
            pIndex.push(0)
            that.setData({
              pageWrapCount: that.data.pageWrapCount.concat([1]),
              pIndex: pIndex
            });
          }
        })
        that.setData({
          category: res.data,
        })
      }
    })
  },
  //点击加载更多
  huoqu: function (e) {
    var that = this
    var index = e.currentTarget.dataset.index
    var current = index
    var id = e.currentTarget.dataset.id
    app.util.request({
      url: 'entry/wxapp/Yuzhen.classb',
      data: { id: id },
      'cachetime': '30',
      success: function (res) {
        console.log(res.data)
        that.setData({
          categoryfl2: res.data,
        })
        app.globalData.skuList = res.data;
        var pIndex = that.data.pIndex
        pIndex.push(current)
        console.log(pIndex, current)
        that.setData({
          pageWrapCount: that.data.pageWrapCount.concat([1]),
          current: current,
          pIndex: pIndex
        });
      }
    })
  },
  //判断是否存在
  existence: function (num, arr) {
    for (var i = 0, len = arr.length; i < len; i++) {
      if (arr[i] == num) {
        return false
      }
    }
    return true
  },
  //搜索
  searchClick: function () {
    wx.navigateTo({
      url: '/hyb_yl/twosubpages/pages/search/search',
    })
  },
  checkClick: function (e) {
    console.log(e)
    // var gId = e.currentTarget.dataset.gId
    var id = e.detail.id
    var title = e.detail.title
    wx.navigateTo({
      url: '/hyb_yl/twosubpages/pages/check/check?id=' + id + '&title=' + title,
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  // huoqu: function (e) {
  //   var that = this

  //   this.setData({
  //     i: e.currentTarget.dataset.index
  //   })

  // },
})